﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Caching;

namespace CombinationAssistant.Common
{
    public class CacheHelper
    {
        public static void AddCacheItem(string key, object item)
        {
            HttpContext.Current.Cache.Remove(key);
            HttpContext.Current.Cache.Add(
                                            key,
                                            item,
                                            null, //dependencies
                                            DateTime.MaxValue, //absolute expiration
                                            new TimeSpan(0, 0, 2, 0), //sliding expiration
                                            CacheItemPriority.Default, //priority
                                            null
                                         ); //callback
        }

        public static object GetItem(string key)
        {
            return HttpContext.Current.Cache.Get(key);
        }
    }

}